package com.cmcc.shared.widget.dialog

import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import com.cmcc.shared.R
import com.cmcc.shared.databinding.SharedDialogProgressBinding

class AppProgressDialog(context: Context) {

    private val binding: SharedDialogProgressBinding =
        SharedDialogProgressBinding.inflate(LayoutInflater.from(context), null, false)

    private val dialog = Dialog(context, R.style.TransparentStyleBottomDialog)

    init {
        //        val inflater = LayoutInflater.from(context)
        dialog.setContentView(binding.root)
        if (context is Activity) {
            val m = context.windowManager
            val d = m.defaultDisplay
            val p = dialog.window!!.attributes
            p.width = (d.width * 0.9).toInt()
            dialog.window!!.attributes = p
        }

    }

    fun show() {
        if (dialog.isShowing)
            dismiss()
        dialog.show()
    }

    fun dismiss() {
        dialog.dismiss()
    }


}